import 'package:flutter/material.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/net/retrofit/activity_api.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/model/activity/activity_detail_bean.dart';
import 'package:flutterlib/model/activity/activity_page_new_query.dart';
import 'package:flutterlib/model/activity/activity_page_query.dart';
import 'package:flutterlib/pages/base/base_sliver_list.dart';
import 'package:flutterlib/widgets/back_button.dart';
import 'package:flutterlib/widgets/bussiness/activity/activity_list_item_new.dart';
import 'package:flutterlib/widgets/bussiness/user_info_widget.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_manger.dart';

class Page extends BaseSliverList {
  final int groupId;

  Page({Key key, this.groupId})
      : super(key: key);

  @override
  PageState createState() => PageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class PageState extends BaseSliverListState<Page>
{
  SimplePullLoadManger manger;
  final SettingsStore store =
  Provider.of<SettingsStore>(currentContext, listen: false);
  ///滑动监听
  final ScrollController scrollController = new ScrollController();

  getDataLogic(int page) async {
    print(page);
    var activitys = await ActivityApi.builder().pageByQuery(
      ActivityPageQuery(
          type: 2,
          pageNum: page,
          smallGroupIds: [widget.groupId],
          status: 1
          ),

    );
    return new DataResult(activitys.list, true);


  }

  Widget renderItem(index, activity) {
    Poi point;
    if(store.myPosition != null){

      point = Poi(longitude: store.myPosition.longitude.toString(), latitude: store.myPosition.latitude.toString());
    }
    return ActivityListItemNew(activity, myLocation: point, onPressed: () {
      NavigatorUtils.gotoActivityDetail(context, activity.id);
    });
  }

  @override
  List<Widget> renderHeader(BuildContext context, bool innerBoxIsScrolled) {
    return <Widget>[];
  }

  @override
  renderActions() {
    return <Widget>[];
  }

  @override
  Widget renderLeading() {
    return MyBackButton(
      color: Colors.black,
    );
  }

  @override
  Widget renderTitle() {
    return Text("兴趣圈活动", style: QuhuiConstant.normalTextBold);
  }

  @override
  bool enablePullDown() {
    return true;
  }

  @override
  bool enablePullUp() {
    return true;
  }
}

